package com.yuanzong.wuliu.service.business.customer.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanzong.wuliu.common.vo.ApiResultPage;
import com.yuanzong.wuliu.mapper.business.customer.BusinessCustomerDaijiaxianDetailsMapper;
import com.yuanzong.wuliu.model.business.customer.BusinessCustomerDaijiaxianDetails;
import com.yuanzong.wuliu.model.business.customer.query.*;
import com.yuanzong.wuliu.service.business.customer.IBusinessCustomerDaijiaxianDetailsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service("businessCustomerDaijiaxianDetailsService")
public class BusinessCustomerDaijiaxianDetailsServiceImpl extends ServiceImpl<BusinessCustomerDaijiaxianDetailsMapper, BusinessCustomerDaijiaxianDetails> implements IBusinessCustomerDaijiaxianDetailsService {

    // 逻辑删除
    protected static final boolean logicalDeleted = false;

    @Autowired
    private BusinessCustomerDaijiaxianDetailsMapper businessCustomerDaijiaxianDetailsMapper;

    //========================================================================================//
    // Service服务接口操作
    //========================================================================================//

    @Override
    public List<BusinessCustomerDaijiaxianDetails> querySubject(BusinessCustomerDaijiaxianDetailsListQuery query) throws Exception {
        List<BusinessCustomerDaijiaxianDetails> businessCustomerDaijiaxianDetailsList = null;
        QueryWrapper<BusinessCustomerDaijiaxianDetails> queryWrapper = new QueryWrapper<>();
        if (query.getDaijiaxianId() != null) {
            queryWrapper.eq("daijiaxian_id", query.getDaijiaxianId());
        }
        queryWrapper.orderByAsc("`sort`");
        businessCustomerDaijiaxianDetailsList = super.getBaseMapper().selectList(queryWrapper);
        return businessCustomerDaijiaxianDetailsList;
    }

    @Override
    public ApiResultPage<BusinessCustomerDaijiaxianDetails> pageSubject(BusinessCustomerDaijiaxianDetailsPageQuery query) throws Exception {
        ApiResultPage<BusinessCustomerDaijiaxianDetails> businessCustomerDaijiaxianDetailsPageList = null;
        Page<BusinessCustomerDaijiaxianDetails> businessCustomerDaijiaxianDetailsPage = new Page<>(query.getPageNum(), query.getPageSize());
        QueryWrapper<BusinessCustomerDaijiaxianDetails> queryWrapper = new QueryWrapper<>();
        businessCustomerDaijiaxianDetailsPage = super.baseMapper.selectPage(businessCustomerDaijiaxianDetailsPage, queryWrapper);
        businessCustomerDaijiaxianDetailsPageList = ApiResultPage.create(query.getPageNum(), query.getPageSize(), businessCustomerDaijiaxianDetailsPage);
        return businessCustomerDaijiaxianDetailsPageList;
    }

    //========================================================================================//
    // HTTP服务接口操作
    //========================================================================================//

    //========================================================================================//
    // extend methods
    //========================================================================================//


    //========================================================================================//
    // The end
    //========================================================================================//

}
